package com.sright.bcard.enterprise.web.controller;

import com.sright.bcard.common.service.share.utils.RedisUtils;
import com.sright.common.response.SrightResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisTestController {

    @Autowired
    private RedisUtils redisUtils;

    @GetMapping("/lock")
    public SrightResponse getLock() {
        Boolean test = redisUtils.lock("test");
        if(test) {
            System.out.println("加锁成功");
        } else {
            redisUtils.releaseLock("test");
        }
        return null;
    }

}
